import { onMounted, ref } from "vue";
export  function getnowtime(){
const newtime = ref("");
const getNowTime = () => {
  var date = new Date();
  let week = new Date().getDay();
  let weeks = ["日", "一", "二", "三", "四", "五", "六"];
  let getWeek = "星期" + weeks[week];
  var time =
    date.getFullYear() +
    "-" +
    (date.getMonth() + 1) +
    "-" +
    addZero(date.getDate()) +
    " " +
    addZero(date.getHours()) +
    ":" +
    addZero(date.getMinutes()) +
    ":" +
    addZero(date.getSeconds()) +
    "---" +
    getWeek;
  newtime.value = time;
};
const addZero = (s) => {
  return s < 10 ? "0" + s : s;
};
onMounted(() => {
  console.log(getNowTime);
  getNowTime();
  clearInterval(myTimeDisplay);
  var myTimeDisplay = setInterval(() => {
    getNowTime();
  }, 1000);
});
return newtime
}

